﻿--lua script
--处理宠物消耗相关的操作

--lua script
--处理英雄相关的操作
--#include "data\functions\Hero\HeroCommon.lua" once			--英雄功能
--#include "data\functions\Hero\HeroRune.lua" once				--英雄符文
--#include "data\functions\Hero\HeroSwing.lua" once				--英雄翅膀
--#include "data\functions\Hero\HeroGodWeapon.lua" once			--英雄神兵
--[[
//英雄的相关操作
enum tagHeroOP
{
	gActivateHero = 1,					//激活英雄
	gHeroReliveCount = 5,				//英雄复活次数
	gHeroCircleLevel = 6,				//英雄转生剩余等级
	gHeroSwingActive = 8,				//英雄翅膀激活
	gHeroSwingState = 9,				//英雄翅膀状态
};
]]


HeroOpFuncList = {}

function SendUplevelResult(sysarg, nSysCmd, eventId, ret)
	local npack = DataPack.allocPacket(sysarg, nSysCmd, eventId)
	if not npack then return end
	DataPack.writeByte(npack, ret)
	DataPack.flush(npack)
end

EventCallDispatcher.HandlerHeroOp = function (sysarg, args)
	if args[1] == nil then 
 		return 
 	end   --第1个参数
 	local func = HeroOpFuncList[args[1]]
 	if func ~= nil then
 		return func(sysarg, args)
 	end
end
EventCallDispatcher.HandlerHeroLogin = function(sysarg)
	OnHeroCommonLogin(sysarg)
end

--激活英雄
HeroOpFuncList[gActivateHero] = function (sysarg,args)
	local heroId = args[2]
	ActivateHero( sysarg, heroId )
end

--设置英雄状态
HeroOpFuncList[gSetHeroState] = function (sysarg,args)
	local heroId 	= args[2]
	local state 	= args[3]
	SetHeroState( sysarg, heroId, state )
end

HeroOpFuncList[gHeroRuneUp] = function (sysarg,args)
	HeroRuneHandle( sysarg )
end

HeroOpFuncList[gHeroCircleUp] = function (sysarg,args)
	local heroId 	= args[2]
	local circle 	= args[3]
	local level 	= args[4]
	HeroCircleHandle( sysarg, heroId, circle, level)
end

HeroOpFuncList[gHeroReliveCount] = function (sysarg,args)
	SendDailyHeroBattleCount(sysarg)
end

HeroOpFuncList[gHeroCircleExchange] = function (sysarg,args)
	local heroId = args[2]
	local level = args[3]
	local circle = args[4]
	SendHeroCircleExchange(sysarg, heroId, level, circle)
end

HeroOpFuncList[gHeroCircleExchangeCount] = function (sysarg,args)
	SendHeroCircleExchangeLastCount(sysarg)
end

HeroOpFuncList[gHeroSwingActive] = function (sysarg,args)
	local heroSwingIdx = args[2]
	ActivateHeroSwing(sysarg, heroSwingIdx)
end

HeroOpFuncList[gHeroSwingState] = function (sysarg,args)
	local heroSwingIdx = args[2]
	local heroSwingState = args[3]
	SetHeroSwingState(sysarg, heroSwingIdx, heroSwingState)
end

HeroOpFuncList[gHeroGodWeapon] = function(sysarg, args)
	local nGwType = args[2]
	HeroGodWeaponLevelUp(sysarg, nGwType)
end

HeroOpFuncList[gHeroSwitchState] = function(sysarg, args)
	local nState = args[2]
	HeroSwitchState(sysarg, nState)
end

EventCallDispatcher.registerEventCall(aeHero, EventCallDispatcher.HandlerHeroOp )
EventCallDispatcher.registerEventCall(aeUserLogin, EventCallDispatcher.HandlerHeroLogin)